import axios from 'axios';
import main from '../main.js';

// import vuex from '../store/index.js';

export function upload(params = {}, url) {
    return axios({
        url: main.$Api + url,
        method: 'post',
        data: params,
        headers: {
            "Content-Type": "multipart/form-data",
            "token": localStorage.getItem('token') || ''
            // "token": JSON.parse(localStorage.getItem('user')) ? JSON.parse(localStorage.getItem('user')).token : ''
        },
        processData: false,
        contentType: false,
    }).then(response => {
        return Promise.resolve(response.data)
    }).catch((error) => {
        return Promise.resolve(error)
    })



    // return axios.post(vuex.state.Api + '/api/file/upload', params, {
    //     headers: {
    //         "Content-Type": "multipart/form-data",
    //         "token": vuex.state.token
    //     }
    // }).then(response => {
    //     return Promise.resolve(response.data)
    // }).catch(error => {
    //     return Promise.resolve(error)
    // })
}